quadrinhosfandomcom_pt_br-20200215-history
Módulo:ComicsInfobox/Citizenship
local valid = { "Abysmian" = "Abysmians", "Afghani" = "Afghans", "African" = "Africans", "American" = "Americans", "Amerikan" = "Amerikans", "Amazon" = "Amazons", "Angolan" = "Angolans", "Apokoliptian" = "Apokoliptians", "Argentinian" = "Argentinians", "Armenian" = "Armenians", "Asgardian" = "Asgardians", "Atlantean" = "Atlanteans", "Attilan" = "Attilans", "Australian" = "Australians", "Austrian" = "Austrians", "Azanian" = "Azanians", "Aztek" = "Azteks", "Balkan" = "Balkans", "Belarusian" = "Belarusians", "Belgian" = "Belgians", "Bhutranian" = "Bhutranians", "Bialyan" = "Bialyans", "Borgonian" = "Borgonians", "Bosnian" = "Bosnians", "Brazilian" = "Brazilians", "British" = "Brits", "Cambodian" = "Cambodians", "Canaanite" = "Canaanites", "Canadian" = "Canadians", "Carib" = "Caribs", "Chinese" = "Chinese", "Colombian" = "Colombians", "Congolese" = "Congolese", "Cooperative" = "Cooperative", Verdean" = "Costa Verdeans", "Croatoan" = "Croatoans", "Cuban" = "Cubans", "Czechoslovakian" = "Czechoslovakians", "Danish" = "Danes", "Delanzan" = "Delanzans", "Delvadian" = "Delvadians", "Dominican" = "Dominicans", "Dutch" = "Dutch", "Egyptian" = "Egyptians", "English" = "English", "Eternal" = "Eternals", "Ethiopian" = "Ethiopians", "European" = "Europeans", "Feitheran" = "Feitherans", "Filipino" = "Filipinos", "Finnish" = "Fins", "French" = "French", "Gamorran" = "Gamorrans", "Gardevian" = "Gardevians", "Genesisian" = "Genesisians", "Georgian" = "Georgians", "German" = "Germans", "Ghanaian" = "Ghanaians", "Ghudazan" = "Ghudazans", City Citizen" = "Gorilla City Citizens", "Greek" = "Greeks", "Guatemalan" = "Guatemalans", "Haitian" = "Haitians", "Hasaraguan" = "Hasaraguans", "Hawaiian" = "Hawaiians", "Hellion" = "Hellions", "Hungarian" = "Hungarians", "Hun" = "Huns", "Icelandic" = "Icelanders", "Ilandian" = "Ilandians", "Indian" = "Indians", "Indonesian" = "Indonesians", "Inniversian" = "Inniversians", "Iranian" = "Iranians", "Iraqi" = "Iraqis", "Irish" = "Irish", "Israeli" = "Israelis", "Israelite" = "Israelites", "Italian" = "Italians", "Jamaican" = "Jamaicans", "Japanese" = "Japanese", "Jarhanpurian" = "Jarhanpurians", "Kandorian" = "Kandorians", "Karlovnan" = "Karlovnans", "Kaznian" = "Kaznians", "Kenyan" = "Kenyans", "Kahndaqi" = "Kahndaqis", "Korean" = "Koreans", "Koran" = "Korans", "Kravian" = "Kravians", "K'un-L'unan" = "K'un-L'unans", "Laotian" = "Laotians", "Latkovian" = "Latkovians", "Latverian" = "Latverians", "Libyan" = "Libyans", "Lithuanian" = "Lithuanians", "M'Changan" = "M'Changans", "Macedonian" = "Macedonians", "Malaysian" = "Malaysians", "Markovian" = "Markovians", "Mayan" = "Mayans", "Mbangawian" = "Mbangawians", "Mexican" = "Mexicans", "Modoran" = "Modorans", "Mongolian" = "Mongols", "Mordanian" = "Mordanians", "Morlaidhan" = "Morlaidhans", "Moroccan" = "Moroccans", "Morovian" = "Morovians", "Narobian" = "Narobians", American" = "Native Americans", "Neosian" = "Neosians", Canaanite" = "New Canaanites", Zealander" = "New Zealanders", "Nicaraguan" = "Nicaraguans", Korean" = "North Koreans", "Norwegian" = "Norwegians", Roman" = "Nova Romans", "Oan" = "Oans", "Olympian" = "Olympians", "Pakistani" = "Pakistanis", "Palestinian" = "Palestinians", "Peruvian" = "Peruvians", "Pokolistani" = "Pokols", "Polish" = "Poles", "Polynesian" = "Polynesians", Rican" = "Puerto Ricans", "Pyromanian" = "Pyromanians", "Quraci" = "Quracis", "Rimborian" = "Rimborians", "Roman" = "Romans", "Romanian" = "Romanians", "Romiroan" = "Romiroans", "Russian" = "Russians", "Samoan" = "Samoans", Diabloan" = "San Diabloans", Priscan" = "Santa Priscans", Arabian" = "Saudi Arabians", "Scandinavian" = "Scandinavians", "Scottish" = "Scots", "Skartarian" = "Skartarians", "Sligs" = "Sligs", "Slorenian" = "Slorenians", "Somalian" = "Somalians", African" = "South Africans", Korean" = "South Koreans", "Soviet" = "Soviets", "Spanish" = "Spanish", "Swedish" = "Swedes", "Swiss" = "Swiss", "Sudanese" = "Sudanese", "Symkarian" = "Symkarians", "Syrian" = "Syrians", "Taiwanese" = "Taiwanese", "Thai" = "Thais", "Tibetan" = "Tibetans", Verdean" = "Tierra Verdeans", "Trans-Sabalian" = "Trans-Sabalians", "Transbelvan" = "Transbelvans", "Transian" = "Transians", "Transylvanian" = "Transylvanians", "Trezygstanian" = "Trezygstanians", "Trojan" = "Trojans", "Tropidoran" = "Tropidorans", "Tynandan" = "Tynandans", "Tundan" = "Tundans", "Tunisian" = "Tunisians", "Turkish" = "Turks", "Ugandan" = "Ugandans", "Ukrainian" = "Ukrainians", Planets Citizen" = "United Planets Citizens", "Venegerian" = "Venegerians", "Venezuelan" = "Venezuelans", "Vietnamese" = "Vietnamese", "Vlatavan" = "Vlatavans", "Wakandan" = "Wakandans", "Welsh" = "Welsh", Lander" = "Wild Landers", "Xibalban" = "Xibalbans", "Yugoslavian" = "Yugoslavs", "Zambesian" = "Zambesians", "Zambian" = "Zambians", "Zandian" = "Zandians", "Zanzibari" ="Zanzibaris", "Zenoshan" = "Zenoshans", } local substitutes = { "abysmia" = "Abysmian", "afghan" = "Afghani", "africa" = "African", "albania" = "Albanian", "america" = "American", "amerika" = "Amerikan", "amazon" = "Amazon", "amazonian" = "Amazon", "angola" = "Angolan", "apokolips" = "Apokoliptian", "argentina" = "Argentinian", "armenia" = "Armenian", "asia" = "Asian", american" = "American", "asian-american" = "American", "asgard" = "Asgardian", "atlantis" = "Atlantean", "attilan" = "Attilan", "austanburg" = "Austanburger", "austrailia" = "Australian", "austria" = "Austrian", "azania" = "Azanian", civilization" = "Aztek", "britain" = "British", "brits" = "British", britain" = "British", "balkan" = "Balkan", "belrusia" = "Belarusian", "bialyan" = "bialyan", "belgium" = "Belgian", "borgonia" = "Borgonian", "bosnia" = "Bosnian", and herzgovina" = "Bosnian", "brazil" = "Brazilian", "cambodia" = "Cambodian", "canaan" = "Canaanite", "canada" = "Canadian", "carib" = "Carib", "caribbean" = "Carib", "china" = "Chinese", "colombia" = "Colombian", "congo" = "Congolese", republic of the congo" = "Congolese", of the congo" = "Congolese", "cooperative" = "Cooperative", verde" = "Costa Verdean", "croatoa" = "Croatoan", "cuba" = "Cuban", "czechoslovakia" = "Czechoslovakian", "danish" = "Danish", "delanza" = "Delanzan", "denmark" = "Danish", "delvadia" = "Delvadian", dominican republic" = "Dominican", republic" = "Dominican", "egypt" = "Egyptian", "england" = "English", "eternals" = "Eternal", "eternal" = "Eternal", "europe" = "European", "ethopia" = "Ethiopian", "feithera" = "Feitheran", "feitheran" = "Feitheran", "finnish" = "Finnish", "finland" = "Finnish", "french" = "French", "france" = "French", kingdom" = "British", "brit" = "British", britain" = "British", "gamorra" = "Gamorran", "gardevia" = "Gardevian", genesis" = "Genisisian", "georgia" = "Georgian", (asia)" = "Georgian", "germany" = "German", "ghana" = "Ghanaian", "ghudaza" = "Ghudazan", city" = "Gorilla City Citizen", "greece" = "Greek", "guatemala" = "Guatemalan", "haiti" = "Haitian", "hasaragua" = "Hasaraguan", "hawaii" = "Hawaiian", "hell" = "Hellion", "holland" = "Dutch", "hungary" = "Hungarian", empire" = "Huns", "iceland" = "Icelandic", "ilandia" = "Ilandian", "india" = "Indian", "indonesia" = "Indonesian", "iran" = "Iranian", "iraq" = "Iraqi", "ireland" = "Irish", "israel" = "Israeli", "italy" = "Italian", "jamaica" = "Jamaican", "japan" = "Japanese", "jarhanpur" = "Jarhanpurian", "kahndaq" = "Kahndaqi", "karlovna" = "Karlovnan", "korans" = "Koran", "kandor" = "Kandorian", "kaznia" = "Kaznian", "korea" = "Korean", "kenyan" = "Kenyan", "kenyans" = "Kenyan", "kenya" = "Kenyan", of israel" = "Israelite", "kravia" = "Kravian", "laos" = "Laotian", "latkovia" = "Latkovian", (amalgam universe)" = "Latkovian", "latveria" = "Latverian", "libya" = "Libyan", "lithuania" = "Lithuanian", "m'changa" = "M'Changan", "macedonia" = "Macedonian", "malaysian" = "Malaysian", "markovia" = "Markovian", "markovians" = "Markovian", civilization" = "Mayan", "mbanangawi" = "Mbangawian", "mexico" = "Mexican", "mexicans" = "Mexican", "modorans" = "Modoran", "modora" = "Modoran", "morlaidh" = "Morlaidhan", "mongolia" = "Mongolian", "mongolians" = "Mongolian", "monk" = "Monk", "mordania" = "Mordanian", "morocco" = "Moroccan", "moroccans" = "Moroccan", "morovia" = "Morovian", "morovians" = "Morovian", american" = "Native American", "native" = "Native American", "neos" = "Neosian", "norweigan" = "Norwegian", "norwegians" = "Norwegian", "narobia" = "Narobian", zealand" = "New Zealander", "dutch" = "Dutch", "netherlands" = "Dutch", "nicaragua" = "Nicaraguan", korea" = "North Korean", "oa" = "Oan", "olympus" = "Olympian", "olympia" = "Olympian", "pakistan" = "Pakistani", "peru" = "Peruvian", "philippines" = "Filipino", philippines" = "Filipino", "pokolistan" = "Pokolistani", "poland" = "Polish", "polynesia" = "Polynesian", rica" = "Puerto Rican", "pyromania" = "Pyromanian", "pyroman" = "Pyromanian", "qurac" = "Quraci", "rimbor" = "Rimborian", "romania" = "Romanian", "rome" = "Roman", "romiro" = "Romiroan", "russia" = "Russian", prisca" = "Santa Priscan", "samoa" = "Samoan", arabia" = "Saudi Arabian", "scandinavia" = "Scandinavian", "scotland" = "Scottish", "skartaris" = "Skartarian", "slorenia" = "Slorenian", "somalia" = "Somalian", africa" = "South African", korea" = "South Korean", union" = "Soviet", "spain" = "Spanish", "sudan" = "Sudanese", "sweden" = "Swedish", "switzerland" = "Swiss", "symkaria" = "Symkarian", "syria" = "Syrian", "themyscira" = "Amazon", "themyscurian" = "Amazon", "themyscurians" = "Amazon", "tynanda" = "Tynandan", soviet union" = "Soviet", "taiwan" = "Taiwanese", "thailand" = "Thai", "tibet" = "Tibetan", verde" = "Tierra Verdean", "trans-sabal" = "Trans-Sabalian", "transbelvia" = "Transbelvan", "transia" = "Transian", "transylvania" = "Transylvanian", "trezygstan" = "Trezygstanian", "tritonis" = "Tritonian", "troy" = "Trojan", "tropidor" = "Tropidoran", "tundi" = "Tundan", "tunisia" = "Tunisian", "turkey" = "Turkish", "uganda" = "Ugandan", "usa" = "American", "us" = "American", states" = "American", "u.s.a." = "American", states of america" = "American", planets" = "United Planets Citizen", kingdom" = "British", "ukraine" = "Ukrainian", of soviet socialist republics" = "Soviet", union" = "Soviet", "ussr" = "Soviet", "u.s.s.r." = "Soviet", "venezuela" = "Venezuelan", "venegaria" = "Venegarian", "vietnam" = "Vietnamese", "vlatava" = "Vlatavan", "wales" = "Welsh", lands" = "Wild Lander", "xanthua" = "Xanthuan", "xibalba" = "Xibalban", "yugoslavia" = "Yugoslavian", "zambesi" = "Zambesian", "zambia" = "Zambian", "zandia" = "Zandian", "zanzibar" = "Zanzibari", "zenosha" = "Zenoshan", } citizenship_table = { "valid" = valid, "substitutes" = substitutes } ---------------------------- -- Libraries of functions -- ---------------------------- -- stands for High Frequency local HF = require('Module:ComicsHF') -- Parses invocation parameters, trims whitespace, and removes blanks. local getArgs = require('Dev:Arguments').getArgs -- Gives the name of the current page. It's expensive, so we only do it once. -- The _G then makes it global, available to all page functions. _G.vars = { Pagename = mw.title.getCurrentTitle().text } ---------------------------------------------------------- -- Public functions (called from a Template or article) -- ---------------------------------------------------------- -- There is no standalone template, so no public functions. -------------------------------------------------------- -- Internal functions (used in this and other Modules -- -------------------------------------------------------- function valid:in_database( name ) if type( self[ name ] ) 'string' then return true else return nil end end function valid:pluralize( name ) if self:in_database ( name ) then return selfname else -- Brute force method of making a singular plural name = name:gsub( 's$', 'es' ) name = name:gsub( 'x$', 'es' ) name = name:gsub( 'z$', 'es' ) name = name:gsub( 'ch$', 'es' ) name = name:gsub( 'sh$', 'es' ) name = name:gsub( 'y$', 'ies' ) name = name:gsub( 'f$', 'ves' ) name = name:gsub( 'fe$', 'ves' ) name = name:gsub( '^s$', '%1s' ) return name end end function valid:link( name ) return HF.CategoryLink( self:pluralize(name), vars.Pagename, name ) end function substitutes:in_list( name ) if type( self[ string.lower( name ) ] ) 'string' then return true else return nil end end function substitutes:sub( name ) if self:in_list( name ) then return self[ string.lower( name ) ] else return nil end end function substitutes:link( name ) return HF.CategoryLink( validname, vars.Pagename, name ) end function citizenship_table._Citizenship( field, vars ) local output = '' local o = {} -- Check for multiple values separated with commas local values = HF.explode( ',', field.Value ) for i, v in ipairs( values ) do v = HF.trim( v ) if valid:in_database( v ) then -- Check if it's a valid value with a plural form. -- If yes - add category links table.insert(o, valid:link( v ) ) elseif substitutes:sub( v ) then -- If it's not valid, check for a direct substitution -- If there's one in the database, use the corrected one table.insert(o, valid:link( substitutes:sub( v ) ) ) elseif string.match( v, '%[%.*%%]' ) then -- If it's already a link, leave it alone. table.insert(o, v) else -- 3. If no substitution is found -- fallback to a common grammar rules -- and add a page to a Category:Needs valid citizenship table.insert( o , valid:link( v ) .. HF.Category( "Needs valid citizenship", vars.Pagename ) ) end end -- If Value2 or ValueRef is provided -- concatenate them to the output if not HF.isempty( field.Value2 ) then output = output .. " " .. field.Value2 end if not HF.isempty( field.ValueRef ) then output = output .. " " .. field.ValueRef end return table.concat(o, ' · ') .. output end ------------------------------------------------- -- Output (send it back to whatever called it) -- ------------------------------------------------- return citizenship_table